# 三种创建方式
# 1、直接建 key:value（已知所有的key：value）
# key 起名有规则的：不可变得数据类型可以作为key：str、number、tuple
info = {
    "stu1801": "ZiQi",
    "stu1802": "XiaoFeng",
    "stu1803": "LiuYu"
}

# 2、先建个空字典，然后加值进去（有未知的，但是随着时间，我就知道值了）
# info_2021[key]=value
info_2021 = {}
info_2021["stu2101"] = "Xiaoming"
print(info_2021)

# 3、dict(key01=value01,key02=value02....)
info_03 = dict(stu1801="ZiQi",stu1802="XiaoFeng",stu1803="LiuYu")
print(info_03)

# * 查询：1、key存不存在？in 2、存在的话---查值value
# print('stu1801' in info_03)
# print('stu1804' in info_03)
print('stu1801' in info_03)
print(info_03['stu1801'])

# dict方法
print(info_03.get('stu1804'))

info_04 = {
    "stu1801":{
        "name":"ZiQi",
        "age":18,
        "info":[2,3,4,5]
        },
    "stu1802":"XiaoFeng",
    "stu1803":"LiuYu"

}
print(info_04["stu1801"]["info"][1])

# get
print(info.get('stu1805'))  #若不存在返回none

# copy
info_05=info.copy()
print(info_05)

# items
print(info.items())

# clear
info_05.clear()
print(info_05)

# fromkeys
seq = ('Google', 'Runoob', 'Taobao')
dict = dict.fromkeys(seq,20)
print(dict)

# keys
print(info.keys())

# values
print(info.values())

# pop
# print(info)
# info.pop('stu1801')
# print(info)

# popitem
# print(info)
# info.popitem()
# print(info)

# setdefault
print(info.setdefault('stu1801'))
print(info.setdefault('stu1805','zhichao'))

# update
info.update(info_04)
print(info)